﻿


function Dictionary() {
    this.data = new Array();

    this.put = function (key, value) {
        this.data[key] = value;
    };

    this.get = function (key) {
        return this.data[key];
    };

    this.remove = function (key) {
        this.data[key] = null;
    };

    this.isEmpty = function () {
        return this.data.length == 0;
    };

    this.size = function () {
        return this.data.length;
    };
}
var ECharts = {

    ChartConfig: function (container, option) {

        var chart_path = "../javascript/echarts/echarts"; //配置图表请求路径 
        var map_path = "../javascript/echarts/echarts-map"; //配置地图的请求路径 

        require.config({//引入常用的图表类型的配置
            paths: {
                echarts: chart_path,
                'echarts/chart/bar': chart_path,
                'echarts/chart/pie': chart_path,
                'echarts/chart/line': chart_path,
                'echarts/chart/k': chart_path,
                'echarts/chart/scatter': chart_path,
                'echarts/chart/radar': chart_path,
                'echarts/chart/chord': chart_path,
                'echarts/chart/force': chart_path,
                'echarts/chart/map': map_path
            }
        });

        this.option = { chart: {}, option: option, container: container };
        return this.option;

    },

    ChartDataFormate: {
        FormateNOGroupData: function (data) {
            //data的格式如上的Result1，这种格式的数据，多用于饼图、单一的柱形图的数据源
            var categories = [];
            var datas = [];
            for (var i = 0; i < data.length; i++) {
                categories.push(data[i].name || "");
                datas.push({ name: data[i].name, value: data[i].value || 0 });
            }
            return { category: categories, data: datas };
        },


        FormateGroupData: function (data, type, is_stack) {
            //data的格式如上的Result2，type为要渲染的图表类型：可以为line，bar，is_stack表示为是否是堆积图，这种格式的数据多用于展示多条折线图、分组的柱图
            var chart_type = 'line';
            if (type)
                chart_type = type || 'line';

            var xAxis = [];
            var group = [];
            var series = [];

            for (var i = 0; i < data.length; i++) {
                for (var j = 0; j < xAxis.length && xAxis[j] != data[i].name; j++);
                if (j == xAxis.length)
                    xAxis.push(data[i].name);

                for (var k = 0; k < group.length && group[k] != data[i].group; k++);
                if (k == group.length)
                    group.push(data[i].group);
            }


            for (var i = 0; i < group.length; i++) {
                var temp = [];
                for (var j = 0; j < data.length; j++) {
                    if (group[i] == data[j].group) {
                        if (type == "map") {
                            temp.push({ name: data[j].name, value: data[i].value });
                        } else {
                            temp.push(data[j].value);
                        }
                    }

                }



                switch (type) {
                    case 'bar':
                        var series_temp = { name: group[i], data: temp, type: chart_type };
                        if (is_stack)
                            series_temp = $.extend({}, { stack: 'stack' }, series_temp);
                        break;

                    case 'map':
                        var series_temp = {
                            name: group[i], type: chart_type, mapType: 'china', selectedMode: 'single',
                            itemStyle: {
                                normal: { label: { show: true} },
                                emphasis: { label: { show: true} }
                            },
                            data: temp
                        };
                        break;

                    case 'line':
                        var series_temp = { name: group[i], data: temp, type: chart_type };
                        if (is_stack)
                            series_temp = $.extend({}, { stack: 'stack' }, series_temp);
                        break;

                    default:
                        var series_temp = { name: group[i], data: temp, type: chart_type };
                }
                series.push(series_temp);
            }
            return { category: group, xAxis: xAxis, series: series };
        }

        ,
        FormateData_As: function (data, type, is_stack) {

            var chart_type = 'map';
            if (type)
                chart_type = type || 'map';
            var geoCoord = "";

            var hospitalnameUnusualscale = [];
            var hospitalnameUnusualscale1 = [];
            var PurchaseCountUnusualscale = [];
            var PurchaseCountUnusualscale1 = [];
            //"{"+stackMap_datas.value_d+"}"     {name: stackMap_datas.name,value:stackMap_datas.value} 
            // { name: "天津市津南区咸水沽医院",value: 22.6415},
            for (var i = 0; i < data.length; i++) {
                //               鄂尔多斯:[109.781327,39.608266]

                //                if (i == 0) {
                //                    var a = "{\"" + data[i].name + "\":[" + data[i].value_d + "],";
                //                    geoCoord = geoCoord + a;
                //                }
                //                else if (i == data.length - 1) {
                //                    var b = "\"" + data[i].name + "\":[" + data[i].value_d + "]" + "}";
                //                    geoCoord = geoCoord + b;
                //                }
                //                else {
                //                    var c = "\"" + data[i].name + "\":[" + data[i].value_d + "],";
                //                    geoCoord = geoCoord + c;
                //                }

                if (data[i].value_type == "1") {
                    hospitalnameUnusualscale.push({ name: data[i].name, value: data[i].value });
                }
                if (data[i].value_type == "2") {
                    PurchaseCountUnusualscale.push({ name: data[i].name, value: data[i].value });
                }
                if (data[i].value_name != null && data[i].value_type == "1") {
                    hospitalnameUnusualscale1.push({ name: data[i].value_name, value: data[i].value_ll });
                }
                if (data[i].value_name != null && data[i].value_type == "2") {
                    PurchaseCountUnusualscale1.push({ name: data[i].value_name, value: data[i].value_ll });
                }
            }
            return { geoCoord: geoCoord, hospitalnameUnusualscale: hospitalnameUnusualscale, hospitalnameUnusualscale1: hospitalnameUnusualscale1, PurchaseCountUnusualscale: PurchaseCountUnusualscale, PurchaseCountUnusualscale1: PurchaseCountUnusualscale1, scale: data[0].scale };
        }
        ,
        FormateData_radar: function (data, type, is_stack) {

            var chart_type = 'radar';
            if (type)
                chart_type = type || 'radar';
            var sortname = [];
            var PurchaseAmount = [];
            var DistributeAmount = [];
            var WarehouseAmount = [];
            for (var i = 0; i < data.length; i++) {
                sortname.push({ text: data[i].name, max: data[0].PurchaseAmountSum });
                PurchaseAmount.push(data[i].PurchaseAmountSum || 0); //,name:"采购金额"
                DistributeAmount.push(data[i].DistributeAmountSum || 0); //,name:"配送金额"
                WarehouseAmount.push(data[i].WarehouseAmountSum || 0); //,name:"入库金额"
            }


            return { sortname: sortname, PurchaseAmount: PurchaseAmount, DistributeAmount: DistributeAmount, WarehouseAmount: WarehouseAmount };
        },
        FormateData_YZ: function (data, type, is_stack) {
            var chart_type = 'line';
            if (type)
                chart_type = type || 'line';
            var sortname = [];
            var purchaseamountmonth = [];
            var DistributeAmountMonth = [];
            var WareHouseAmountMonth = [];
            var maxpurchaseamount = 0;
            //            var a1 = new Dictionary();     
            for (var i = 0; i < data.length; i++) {
                sortname.push(data[i].sortname);
                if (data[i].purchaseamountmonth >= maxpurchaseamount) {
                    maxpurchaseamount = data[i].purchaseamountmonth;
                }
                purchaseamountmonth.push(data[i].purchaseamountmonth || 0); //,name:"采购金额"
                DistributeAmountMonth.push(data[i].DistributeAmountMonth || 0); //,name:"配送金额"
                WareHouseAmountMonth.push(data[i].WareHouseAmountMonth || 0); //,name:"入库金额"
            }


            return { max: maxpurchaseamount, sortname: sortname, purchaseamountmonth: purchaseamountmonth, DistributeAmountMonth: DistributeAmountMonth, WareHouseAmountMonth: WareHouseAmountMonth };
            //            for (var i = 0; i < data.length; i++) {


            //                if (data[i].sortname == "血管介入类") {
            //                    purchaseamountmonth.
            //                }
            //                if (data[i].sortname == "非血管介入类") {
            //                    a2.put(data[i].PurchaseMonth, [5007.21, 2578.03, 6921.29, 2855.23, 2388.38, 6002.54, 2662.08, 4057.4, 6694.23, 12442.87, 9705.02, 3923.11, 4983.67, 2807.41, 12078.15, 6867.7, 4757.45, 4659.99, 15844.64, 2821.11, 713.96, 2555.72, 5333.09, 1426.34, 2556.02, 185.09, 2587.72, 1399.83, 390.2, 445.36]);
            //                }
            //                if (data[i].sortname == "骨科植入") {
            //                    a3.put(data[i].PurchaseMonth, [635.56, 112.79, 199.87, 118.48, 55.89, 145.38, 73.15, 32.2, 517.97, 392.11, 451.54, 87.45, 150.09, 64.31, 329.71, 165.11, 107.31, 99.35, 534.28, 61.59, 10.68, 147.04, 206.24, 48.01, 105.48, 4.74, 77.87, 42.31, 17.98, 24.8]);
            //                }
            //                if (data[i].sortname == "神经外科") {
            //                    a4.put(data[i].PurchaseMonth, [341.88, 92.31, 185.19, 78.73, 61.05, 188.49, 91.99, 127.2, 487.82, 447.47, 473.16, 162.63, 215.84, 138.02, 418.21, 217.58, 176.8, 186.49, 955.66, 100.93, 25.14, 113.69, 231.72, 59.86, 103.79, 4.35, 83.9, 48.09, 11.41, 16.85]);
            //                }
            //                //'血管介入类', '非血管介入类', '骨科植入', '神经外科', '电生理类', '起搏器类', '体外循环及血液净化', '眼科材料', '口腔科', '其他'
            //                if (data[i].sortname == "电生理类") {
            //                    a5.put(data[i].PurchaseMonth, [84.11, 89.91, 1064.05, 215.19, 420.1, 615.8, 488.23, 504.8, 81.02, 1162.45, 717.85, 749.4, 692.94, 560, 1480.67, 1198.7, 798.35, 886.47, 1072.91, 658.78, 244.29, 339.06, 1128.61, 298.69, 494.6, 40.7, 302.66, 237.91, 48.47, 55.63]);
            //                }
            //                if (data[i].sortname == "起搏器类") {
            //                    a6.put(data[i].PurchaseMonth, [1487.15, 1337.31, 3417.56, 1463.38, 967.49, 2898.89, 1098.37, 2084.7, 3209.02, 6787.11, 5096.38, 1535.29, 2340.82, 1204.33, 6485.05, 3310.14, 1956.02, 1777.74, 7592.78, 984.08, 175.82, 1135.31, 2014.8, 569.37, 1047.66, 47.64, 1221.17, 572.02, 171.92, 194.27]);
            //                }
            //                if (data[i].sortname == "体外循环及血液净化") {
            //                    a7.put(data[i].PurchaseMonth, [3435.95, 1150.81, 2439.68, 1176.65, 1000.79, 2487.85, 1075.48, 1467.9, 3404.19, 4493.31, 3890.79, 1638.42, 1949.91, 1043.08, 4112.43, 2358.86, 2003.08, 1995.78, 7178.94, 1178.25, 293.85, 1081.35, 2189.68, 558.28, 1013.76, 96.76, 1063.89, 589.91, 169.81, 195.46]);
            //                }
            //                if (data[i].sortname == "眼科材料") {
            //                    a8.put(data[i].PurchaseMonth, [4092.27, 1319.76, 2805.47, 1375.67, 1270, 2811.95, 1223.64, 1657.77, 4097.26, 5198.03, 4584.22, 1963.9, 2206.02, 1225.8, 4764.7, 2722.4, 2292.55, 2428.95, 8335.3, 1361.92, 335.3, 1229.62, 2510.3, 661.8, 1192.53, 123.3, 1234.6, 688.41, 193.7, 227.73]);
            //                }
            //                if (data[i].sortname == "口腔科") {
            //                    a9.put(data[i].PurchaseMonth, [6033.21, 3110.97, 8477.63, 3571.37, 3041.07, 6672, 3122.01, 4750.6, 8072.83, 15003.6, 11648.7, 4759.3, 5763.35, 3456.7, 15021.84, 8553.79, 5633.24, 5641.94, 18864.62, 3433.5, 819.66, 3034.58, 6379.63, 1677.8, 3081.91, 220.34, 3175.58, 1688.49, 466.1, 537.11]);
            //                }
            //                if (data[i].sortname == "其他") {
            //                    a10.put(data[i].PurchaseMonth, [436.11, 106.14, 231.08, 95.1, 73.81, 203.1, 97.93, 137.74, 666.3, 534.17, 587.83, 188.28, 248.44, 167.2, 473.27, 236.44, 204.8, 191.5, 1103.75, 122.52, 30.64, 129.12, 264.3, 68.3, 116.54, 5.8, 95.9, 56.84, 13, 20.78]);
            //                }

            //            }

            //            return { _a1: a1, _a2: a2, _a3: a3, _a4: a4, _a5: a5, _a6: a6, _a7: a7, _a8: a8, _a9: a9, _a10: a10 };
        },
        FormateData: function (data, type, is_stack) {

            var chart_type = 'line';
            if (type)
                chart_type = type || 'line';
            var xAxis = [];
            var group = [];
            var series = [];
            var values = [];
            var value_ds = [];
            for (var i = 0; i < data.length; i++) {
                for (var j = 0; j < xAxis.length; j++); // && xAxis[j] != data[i].name
                if (j == xAxis.length) {
                    if (data[i].name.length < 7) {
                        xAxis.push(data[i].name);
                    }
                    else {
                        var a = data[i].name.length;
                        var dataname = "";
                        var it = Math.floor((a / 6));
                        for (var ii = 1; ii <= it; ii++) {
                            dataname += data[i].name.substring(6 * (ii - 1), 6 * ii) + "\n";
                        }

                        dataname += data[i].name.substring(6 * it, a);
                        xAxis.push(dataname);
                    }
                }

                for (var k = 0; k < group.length; k++); //&& group[k] != data[i].group
                if (k == group.length)
                    group.push(data[i].group);
                for (var c = 0; c < values.length; c++); // && values[c] != data[i].value
                if (c == values.length)
                    values.push(data[i].value);
                for (var d = 0; d < value_ds.length; d++); //&& value_ds[d] != data[i].value
                if (d == value_ds.length)
                    value_ds.push(data[i].value_d);
            }
            //            for (var i = 0; i < group.length; i++) {
            //                var temp = [];
            //                for (var j = 0; j < data.length; j++) {
            //                    if (group[i] == data[j].group) {

            //                        temp.push(data[j].value);

            //                    }

            //                }
            //                switch (type) {
            //                    case 'line':
            //                        var series_temp = { name: group[i], data: temp, type: chart_type };
            //                        if (is_stack)
            //                            series_temp = $.extend({}, { stack: 'stack' }, series_temp);
            //                        break;

            //                    default:
            //                        var series_temp = { group: group[i], value: temp, type: chart_type };
            //                }
            //                series.push(series_temp);
            // }
            return { category: name, xAxis: xAxis, series: series, group: group, values: values, value_d: value_ds };
        }

      
    } ,



    ChartOptionTemplates: {
        CommonOption: {
            //通用的图表基本配置 
            tooltip: {
                trigger: 'axis'//tooltip触发方式:axis以X轴线触发,item以每一个数据项触发 
            },
            toolbox: {
                show: true, //是否显示工具栏 
                feature: {
                    mark: true,
                    dataView: { readOnly: false }, //数据预览 
                    restore: true, //复原 
                    saveAsImage: true //是否保存图片 
                }
            }
        },

        CommonLineOption: {//通用的折线图表的基本配置 
            tooltip: {
                trigger: 'axis'
            },
            calculable: true,
            toolbox: {
                show: true,
                feature: {
                    dataView: { readOnly: false }, //数据预览
                    restore: true, //复原
                    saveAsImage: true, //是否保存图片
                    magicType: ['line', 'bar']//支持柱形图和折线图的切换 
                }
            }
        },


        Pie: function (data, name) {
            //data:数据格式：{name：xxx,value:xxx}...
            var pie_datas = ECharts.ChartDataFormate.FormateNOGroupData(data);

            var option = {
                title: {
                    text: '地区采购分布',

                    x: 'center'
                },
                tooltip: {
                    trigger: 'item',
                    formatter: '{b} : {c} ({d}/%)',
                    show: true
                },

                legend: {
                    orient: 'vertical',
                    x: 'left',
                    data: pie_datas.category
                },

                calculable: true,

                toolbox: {
                    show: true,
                    feature: {
                        mark: { show: true },
                        dataView: { show: true, readOnly: true },
                        restore: { show: true },
                        saveAsImage: { show: true }
                    }
                },
                series: [
                    {
                        name: name || "",
                        type: 'pie',
                        radius: '65%',
                        center: ['50%', '50%'],
                        data: pie_datas.data
                    }
                ]
            };
            return $.extend({}, ECharts.ChartOptionTemplates.CommonOption, option);
        },
        Pie2: function (data, name) {
            //data:数据格式：{name：xxx,value:xxx}...
            var pie_datas = ECharts.ChartDataFormate.FormateNOGroupData(data);
            option = {
                title: {
                    text: '配送企业覆盖医院数',
                    subtext: '排名前十',
                    x: 'right',
                    y: 'bottom'
                },
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                legend: {
                    orient: 'vertical',
                    x: 'left',
                    data: pie_datas.category
                },
                toolbox: {
                    show: true,
                    feature: {
                        mark: { show: true },
                        dataView: { show: true, readOnly: false },
                        restore: { show: true },
                        saveAsImage: { show: true }
                    }
                },
                calculable: false,
                series: (function () {
                    var series = [];
                    for (var i = 0; i < 30; i++) {
                        series.push({
                            name: '配送企业覆盖医院数（排名前十）',
                            type: 'pie',
                            itemStyle: { normal: {
                                label: { show: i > 28 },
                                labelLine: { show: i > 28, length: 20 }
                            }
                            },
                            radius: [i * 4 + 40, i * 4 + 43],
                            data: pie_datas.data
                        })
                    }
                    series[0].markPoint = {
                        symbol: 'emptyCircle',
                        symbolSize: series[0].radius[0],
                        effect: { show: true, scaleSize: 12, color: 'rgba(250,225,50,0.8)', shadowBlur: 10, period: 30 },
                        data: [{ x: '50%', y: '50%'}]
                    };
                    return series;
                })()
            };


            return $.extend({}, ECharts.ChartOptionTemplates.CommonOption, option);
        },


        Pie3: function (data, name) {
            //data:数据格式：{name：xxx,value:xxx}...
            var pie_datas = ECharts.ChartDataFormate.FormateNOGroupData(data);
            option = {
                title: {
                    text: '结算发票审核状态统计',
                    subtext: '统计数量',
                    x: 'right',
                    y: 'bottom'
                },
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                legend: {
                    orient: 'vertical',
                    x: 'left',
                    data: pie_datas.category
                },
                toolbox: {
                    show: true,
                    feature: {
                        mark: { show: true },
                        dataView: { show: true, readOnly: false },
                        restore: { show: true },
                        saveAsImage: { show: true }
                    }
                },
                calculable: false,
                series: (function () {
                    var series = [];
                    for (var i = 0; i < 30; i++) {
                        series.push({
                            name: '结算发票审核状态统计百分比',
                            type: 'pie',
                            itemStyle: {
                                normal: {
                                    label: { show: i > 28 },
                                    labelLine: { show: i > 28, length: 20 }
                                }
                            },
                            radius: [i * 4 + 40, i * 4 + 43],
                            data: pie_datas.data
                        })
                    }
                    series[0].markPoint = {
                        symbol: 'emptyCircle',
                        symbolSize: series[0].radius[0],
                        effect: { show: true, scaleSize: 12, color: 'rgba(250,205,10,1.8)', shadowBlur: 10, period: 35 },
                        //effect: { show: true, scaleSize: 12, color: 'rgba(250,225,50,0.8)', shadowBlur: 10, period: 30 },
                        data: [{ x: '50%', y: '50%'}]
                    };
                    return series;
                })()
            };
            return $.extend({}, ECharts.ChartOptionTemplates.CommonOption, option);
        },
        Lines: function (data, name, is_stack) {
            //data:数据格式：{name：xxx,group:xxx,value:xxx}... 
            var stackline_datas = ECharts.ChartDataFormate.FormateGroupData(data, 'line', is_stack);
            var option = {
                legend: { data: stackline_datas.category
                },

                xAxis: [{
                    type: 'category', //X轴均为category，Y轴均为value 
                    data: stackline_datas.xAxis,
                    boundaryGap: false//数值轴两端的空白策略 
                }],

                yAxis: [{
                    name: name || '',
                    type: 'value',
                    splitArea: { show: true }
                }],
                series: stackline_datas.series
            };
            return $.extend({}, ECharts.ChartOptionTemplates.CommonLineOption, option);
        },
        Lines_NM:function()
        {
            //data:数据格式：{name：xxx,group:xxx,value:xxx}... 
            //var stackline_datas = ECharts.ChartDataFormate.FormateGroupData(data, 'line', is_stack);
            option = {
                title: {
                    text: '价格曲线图',
                    subtext: '纯属虚构'
                },
                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data: ['价格波动曲线']
                },
                toolbox: {
                    show: true,
                    feature: {
                        mark: { show: true },
                        dataView: { show: true, readOnly: false },
                        magicType: { show: true, type: ['line', 'bar'] },
                        restore: { show: true },
                        saveAsImage: { show: true }
                    }
                },
                calculable: true,
                xAxis: [
                    {
                        type: 'category',
                        boundaryGap: false,
                        data: ['最低价', '平均价', '中位价', '加权平均价', '参考价', '最高价'
                        ]
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        axisLabel: {
                            formatter: '{value} 元'
                        }
                    }
                ],
                series: [
                    {
                        name: '',
                        type: 'line',
                        data: [6, 7, 8, 8, 10, 9],
                        markPoint: {
                            data: [
                                { name: '最低价', xAxis: '最低价', yAxis: 6, value: 6, itemStyle: { normal: { color: '#44BB44', label: { position: 'inside' } } } },
                                { name: '平均价', xAxis: '平均价', yAxis: 7, value: 7, itemStyle: { normal: { color: '#44BB44', label: { position: 'inside' } } } },
                                { name: '中位价', xAxis: '中位价', yAxis: 8, value: 8, itemStyle: { normal: { color: '#B39E4D', label: { position: 'inside' } } } },
                                { name: '加权平均价', xAxis: '加权平均价', yAxis: 8, value: 8, itemStyle: { normal: { color: '#D5D52B', label: { position: 'inside' } } } },
                                { name: '参考价', xAxis: '参考价', yAxis: 10, value: 10, itemStyle: { normal: { color: '#FF0033', label: { position: 'inside' } } } },
                                { name: '最高价', xAxis: '最高价', yAxis: 9, value: 9, itemStyle: { normal: { color: '#FF0033', label: { position: 'inside' } } } }
                            ]
                        },
                        markLine: {
                            data: [
                              { type: 'average', name: '当前价格', itemStyle: { normal: { color: '#CC00FF' } } }

                            ],
                            effect: {
                                show: true
                            }
                        }
                    }
                ]
            }
        },
        lines_HS: function (data, name, is_stack) {
            //data:数据格式：{name：xxx,group:xxx,value:xxx}... 
            var stackline_datas = ECharts.ChartDataFormate.FormateData(data, 'line', is_stack);
            option = {
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    }
                },
                legend: {
                    data: ['采购金额', '配送金额', '入库金额']
                },
                toolbox: {
                    show: true,
                    orient: 'vertical',
                    x: 'right',
                    y: 'center',
                    feature: {
                        mark: { show: true },
                        dataView: { show: true, readOnly: false },
                        magicType: { show: true, type: ['line', 'bar', 'stack', 'tiled'] },
                        restore: { show: true },
                        saveAsImage: { show: true }
                    }

                },
                calculable: true,
                xAxis: [
        {
            type: 'category',
            position: 'bottom',

            boundaryGap: true,
            axisLine: {    // 轴线
                show: true,
                lineStyle: {
                    color: 'green',
                    type: 'solid',
                    width: 2
                }
            },
            axisTick: {    // 轴标记
                show: true,
                length: 10,
                lineStyle: {
                    color: 'red',
                    type: 'solid',
                    width: 2
                }
            },
            axisLabel: {
                show: true,
                interval: 0,    // {number}
                rotate: 45,
                margin: 8,
                formatter: '{value}',
                textStyle: {
                    color: 'blue',
                    fontFamily: 'sans-serif',
                    fontSize: 10,
                    fontStyle: 'normal',
                    fontWeight: 'bold'

                }
            },
            splitLine: {
                show: true,
                lineStyle: {
                    color: '#483d8b',
                    type: 'dashed',
                    width: 1
                }
            },
            splitArea: {
                show: true,
                areaStyle: {
                    color: ['rgba(144,238,144,0.3)', 'rgba(135,200,250,0.3)']
                }
            },
            data: stackline_datas.xAxis
        }
    ],
                yAxis: [
        {
            type: 'value'
        }
    ],
                series: [
        {
            name: '采购金额',
            type: 'bar',
            data: stackline_datas.group
        },
        {
            name: '配送金额',
            type: 'bar',
            data: stackline_datas.value_d
        },
        {
            name: '入库金额',
            type: 'bar',
            data: stackline_datas.values
        }
    ]
            };

            return $.extend({}, ECharts.ChartOptionTemplates.CommonLineOption, option);
        },

        lines_YZ: function (data, name, is_stack) {
            //data:数据格式：{name：xxx,group:xxx,value:xxx}... 
            var myDate = new Date();

            var stackline_datas = ECharts.ChartDataFormate.FormateData_YZ(data, 'line', is_stack);

            option = {
                tooltip: {
                    trigger: 'axis'
                },
                toolbox: {
                    show: true,
                    feature: {
                        mark: { show: true },
                        dataView: { show: true, readOnly: false },
                        magicType: { show: true, type: ['line', 'bar'] },
                        restore: { show: true },
                        saveAsImage: { show: true }
                    }
                },
                calculable: true,
                legend: {
                    data: ['采购金额', '配送金额', '入库金额']
                },
                xAxis: [
        {
            type: 'category',
            position: 'bottom',

            boundaryGap: true,
            axisLine: {    // 轴线
                show: true,
                lineStyle: {
                    color: 'green',
                    type: 'solid',
                    width: 2
                }
            },
            axisTick: {    // 轴标记
                show: true,
                length: 10,
                lineStyle: {
                    color: 'red',
                    type: 'solid',
                    width: 2
                }
            },
            axisLabel: {
                show: true,
                interval: 0,    // {number}
                rotate: 45,
                margin: 8,
                formatter: '{value}',
                textStyle: {
                    color: 'blue',
                    fontFamily: 'sans-serif',
                    fontSize: 10,
                    fontStyle: 'normal',
                    fontWeight: 'bold'

                }
            },
            splitLine: {
                show: true,
                lineStyle: {
                    color: '#483d8b',
                    type: 'dashed',
                    width: 1
                }
            },
            type: 'category',
            data: stackline_datas.sortname
            //['血管介入类', '非血管介入类', '骨科植入', '神经外科', '电生理类', '起搏器类', '体外循环及血液净化', '眼科材料', '口腔科', '其他']
        }
    ],
                yAxis: [
        {
            type: 'value',
            name: '采购额',
            axisLabel: {
                formatter: '{value} ￥'
            },
            max: stackline_datas.max + 2000000
        }
                //        ,
                //        {
                //            type: 'value',
                //            name: '入库额',
                //            axisLabel: {
                //                formatter: '{value} ￥'
                //            }
                //        }
    ],
                series: [

        {
            name: '采购金额',
            type: 'bar',
            data: stackline_datas.purchaseamountmonth
        },
        {
            name: '配送金额',
            type: 'bar',
            data: stackline_datas.DistributeAmountMonth
        },
        {
            name: '入库金额',
            type: 'bar',
            //yAxisIndex: 1,
            data: stackline_datas.WareHouseAmountMonth
        }
    ]
            };

            return $.extend({}, ECharts.ChartOptionTemplates.CommonLineOption, option);
        },
        Lines6: function (data, name, is_stack) {
            //data:数据格式：{name：xxx,group:xxx,value:xxx}... 
            var stackline_datas = ECharts.ChartDataFormate.FormateData(data, 'line', is_stack);
            option = {
                title: {
                    text: '医院统计',
                    subtext: '',
                    x: 'center'
                },
                tooltip: {
                    trigger: 'axis',
                    formatter: function (v) {
                        return v[0][1] + '<br/>'
                   + v[0][0] + ' : ' + v[0][2] + ' (元)<br/>'
                   + v[1][0] + ' : ' + -v[1][2] + ' (元)';
                    }
                },
                legend: {
                    data: ['采购金额', '入库金额'],
                    x: 'left'
                },
                toolbox: {
                    show: true,
                    feature: {
                        mark: { show: true },
                        dataView: { show: true, readOnly: false },
                        magicType: { show: true, type: ['bar', 'line'] },
                        restore: { show: true },
                        saveAsImage: { show: true }
                    }
                },
                dataZoom: {
                    show: true,
                    realtime: true,
                    start: 0,
                    end: 1000
                },
                xAxis: [
        {
            type: 'category',
            boundaryGap: false,
            axisLine: { onZero: false },
            data: stackline_datas.xAxis
        }
    ],
                yAxis: [
        {
            name: '采购金额',
            type: 'value',
            max: 100000000
        },
        {
            name: '入库金额',
            type: 'value',
            axisLabel: {
                formatter: function (v) {
                    return -v;
                }
            }
        }
    ],
                series: [
        {
            name: '采购金额',
            type: 'line',
            itemStyle: { normal: { areaStyle: { type: 'default'}} },
            data: stackline_datas.group
        },
        {
            name: '入库金额',
            type: 'line',
            yAxisIndex: 1,
            itemStyle: { normal: { areaStyle: { type: 'default'}} },
            data: (function () {
                var oriData = stackline_datas.values;
                var len = oriData.length;
                while (len--) {
                    oriData[len] *= -1;
                }
                return oriData;
            })()
        }
    ]
            };

            return $.extend({}, ECharts.ChartOptionTemplates.CommonLineOption, option);
        },

        Bars: function (data, name, is_stack) {
            //data:数据格式：{name：xxx,group:xxx,value:xxx}...
            var bars_dates = ECharts.ChartDataFormate.FormateGroupData(data, 'bar', is_stack);
            var option = {
                legend: bars_dates.category,
                xAxis: [{
                    type: 'category',
                    data: bars_dates.xAxis,
                    axisLabel: {
                        show: true,
                        interval: 'auto',
                        rotate: 0,
                        margion: 8
                    }
                }],

                yAxis: [{
                    type: 'value',
                    name: name || '',
                    splitArea: { show: true }
                }],
                series: bars_dates.series
            };
            return $.extend({}, ECharts.ChartOptionTemplates.CommonLineOption, option);
        },
        radar: function (data, name, is_stack) {
            var radar_dates = ECharts.ChartDataFormate.FormateData_radar(data, 'radar', is_stack);
            var option = {
                title: {
                    text: '高值大类采购分析',
                    subtext: '雷达图'
                },
                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    orient: 'vertical',
                    x: 'right',
                    y: 'bottom',
                    selectedMode: 'multiple',
                    data: ['采购金额', '配送金额', '入库金额']
                },
                toolbox: {
                    show: true,
                    feature: {
                        mark: { show: true },
                        dataView: { show: true, readOnly: false },
                        restore: { show: true },
                        saveAsImage: { show: true }
                    }
                },
                polar: [
       {
           indicator: radar_dates.sortname
       }
    ],
                calculable: true,
                series: [
        {
            name: '高值大类采购分析',
            type: 'radar',
            data: [
                {
                    value: radar_dates.PurchaseAmount,
                    name: '采购金额'
                },
                 {
                     value: radar_dates.DistributeAmount,
                     name: '配送金额'
                 },
                 {
                     value: radar_dates.WarehouseAmount,
                     name: '入库金额'
                 }
            ]
        }
    ]
            };
            return $.extend({}, ECharts.ChartOptionTemplates.CommonLineOption, option);
        }
        ,
        Map_AS: function (dt, name, is_stack) {
            //data:数据格式：{name：xxx,group:xxx,value:xxx}... 
            var stackMap_datas = ECharts.ChartDataFormate.FormateData_As(dt, 'map', is_stack);

            option = {
                title: {
                    text: '高值医用耗材预测预警',
                    //                    subtext: 'data from PM25.in',
                    //                    sublink: 'http://www.pm25.in',
                    x: 'center'
                },
                tooltip: {
                    trigger: 'item',
                    //show: true,   //default true
                    showDelay: 0,
                    hideDelay: 50,
                    transitionDuration: 0,
                    backgroundColor: 'rgba(255,0,255,0.7)',
                    borderColor: '#AB82FF',
                    borderRadius: 8,
                    borderWidth: 2,
                    padding: 5,
                    textStyle: {
                        color: 'yellow',
                        decoration: 'none',
                        fontFamily: 'Verdana, sans-serif',
                        fontSize: 15,
                        fontStyle: 'italic',
                        fontWeight: 'bold'
                    },
                    formatter: function (params, ticket, callback) {
                        console.log(params)
                        var res = '异常数据比例: <br/>' + params[1] + params[2] + "%";
                        //                        for (var i = 0, l = params.length; i < l; i++) {
                        //                            res += '<br/>' + params[i].stackMap_datas.hospitalnameUnusualscale.name + ' : ' + params[i].stackMap_datas.hospitalnameUnusualscale.value;
                        //                        }
                        setTimeout(function () {
                            // 仅为了模拟异步回调
                            callback(ticket, res);
                        }, 1000)
                        return 'loading';
                    }

                },

                legend: {

                    orient: 'vertical',
                    x: 'left',
                    selectedMode: 'single',
                    selected: {
                        '采购量预警': false
                    },
                    data: ["价格预警", "采购量预警"]
                },
                roamController: {
                    show: true,
                    x: 'right',
                    mapTypeControl: {
                        '天津': true
                    }
                },
                dataRange: {
                    min: 0,
                    max: stackMap_datas.scale,
                    calculable: false,
                    color: ['red', 'yellow', 'green']
                },
                toolbox: {
                    show: true,
                    orient: 'vertical',
                    x: 'right',
                    y: 'center',
                    feature: {
                        mark: { show: true },
                        dataView: { show: true, readOnly: false },
                        restore: { show: true },
                        saveAsImage: { show: true }
                    }
                },
                series: [
        {
            name: '价格预警',
            type: 'map',
            mapType: '天津',
            hoverable: false,
            roam: true,
            data: [],


            itemStyle: {
                normal: {
                    borderWidth: 1,
                    borderColor: '#0066CC',
                    color: '#3399FF',
                    label: {
                        show: true
                    }
                },
                emphasis: {                 // 也是选中样式
                    borderWidth: 1,
                    borderColor: '0066CC',
                    color: '#3399FF',
                    label: {
                        show: true,
                        textStyle: {
                            color: '#0066CC'
                        }
                    }
                }
            },

            markPoint: {
                symbolSize: 5,       // 标注大小，半宽（半径）参数，当图形为方向或菱形则总宽度为symbolSize * 2
                itemStyle: {
                    normal: {
                        borderColor: '#0066CC',
                        borderWidth: 1,            // 标注边线线宽，单位px，默认为1
                        label: {
                            show: false
                        }
                    },
                    emphasis: {
                        borderColor: '#000066',
                        borderWidth: 1,
                        label: {
                            show: false
                        }
                    }
                },
                data: stackMap_datas.hospitalnameUnusualscale
            }
            ,

            geoCoord: { "天津市北辰区中医医院": [117.139, 39.2361], "天津市宝坻区钰华医院": [117.301, 39.6997], "天津市宝坻区人民医院": [117.315, 39.7253], "天津市宝坻区王卜庄医院": [117.451, 39.6904], "天津市宝坻区中医医院": [117.312, 39.7174], "天津市东丽区中医医院": [117.317, 39.0903], "天津市滨海新区汉沽医院": [117.807, 39.2503], "天津市滨海新区汉沽中医医院": [117.818, 39.2486], "天津市海河医院": [117.198, 39.115], "天津市和平区新兴街社区卫生服务中心": [117.196, 39.1071], "天津市和平区牙科医院": [117.193, 39.1346], "天津市和平区中医医院": [117.201, 39.1117], "天津市河西区挂甲寺街社区卫生服务中心": [117.244, 39.0963], "天津市河西区康复医院": [117.228, 39.1167], "天津市河西区口腔医院": [117.221, 39.1154], "海洋石油总医院": [117.708, 38.9976], "天津市静海县中医医院": [116.924, 38.9401], "天津市津南区咸水沽医院": [117.39, 38.9997], "天津市蓟县人民医院": [117.431, 40.0507], "天津市蓟县中医医院": [117.414, 40.0485], "天津市宁河县潘庄医院": [117.481, 39.3514], "天津市宁河县中医院": [117.689, 39.3816], "天津市南开区三潭医院": [117.161, 39.126], "天津市南开区王顶堤医院": [117.152, 39.0918], "天津医科大学第二医院": [117.227, 39.0901], "天津市滨海新区塘沽传染病医院": [117.615, 39.0379], "天津市滨海新区塘沽中医医院": [117.641, 39.0466], "天津市北辰医院": [117.138, 39.2318], "天津市第二人民医院": [117.157, 39.1171], "天津市中医药研究院附属医院": [117.184, 39.1522], "天津市大港医院": [117.483, 38.8376], "天津市东丽区东丽医院": [117.333, 39.1231], "天津市儿童医院": [117.205, 39.107], "天津市公安医院": [117.219, 39.1225], "天津港口医院": [117.724, 39.0089], "天津市环湖医院": [117.189, 39.0952], "天津市红桥医院": [117.164, 39.1878], "天津市黄河医院": [117.151, 39.144], "天津华兴医院": [117.454, 38.8535], "天津市静海县医院": [116.93, 38.9312], "天津市口腔医院": [117.212, 39.1334], "天津市宁河县医院": [117.834, 39.3413], "天津市南开医院": [117.177, 39.1337], "天津市人民医院": [117.163, 39.1527], "天津市泰达医院": [117.723, 39.0334], "天津市第五中心医院": [117.655, 39.0216], "天津市天津医院": [117.238, 39.0997], "天津市胸科医院": [117.393, 38.9698], "天津市西青医院": [117.027, 39.15], "天津市永久医院": [117.679, 39.0221], "天津市眼科医院": [117.192, 39.1305], "天津市职业病防治院": [117.246, 39.1587], "天津市肿瘤医院": [117.191, 39.0873], "泰达国际心血管病医院": [117.723, 39.0334], "天津市武清区人民医院": [117.06, 39.3868], "天津市武清区中医医院": [117.086, 39.3902], "天津医科大学代谢病医院": [117.19, 39.1103], "天津医科大学口腔医院": [117.192, 39.1104], "天津医科大学眼科中心": [117.127, 39.1041], "天津医科大学总医院": [117.193, 39.1238], "大港油田集团职工总医院": [117.51, 38.7464], "天津市第一医院": [117.195, 39.1859], "天津市第二医院": [117.199, 39.1565], "天津市第三医院": [117.247, 39.1591], "天津市第四医院": [117.27, 39.0674], "天津市第一中心医院": [117.159, 39.1062], "天津市第三中心医院": [117.256, 39.116], "天津市第四中心医院": [117.216, 39.1704], "天津中医药大学第二附属医院": [117.234, 39.1558], "天津中医药大学第一附属医院": [117.171, 39.1206] }
        },
        {
            name: '价格预警',
            type: 'map',
            mapType: '天津',
            data: [],
            markPoint: {
                symbol: 'emptyCircle',
                symbolSize: function (v) {
                    return 5 + v / 100
                },
                effect: {
                    show: true,
                    shadowBlur: 0
                },
                itemStyle: {
                    normal: {
                        label: { show: false }
                    }
                },
                data: stackMap_datas.hospitalnameUnusualscale1
            }
        },
        {
            name: '采购量预警',
            type: 'map',
            mapType: '天津',
            hoverable: false,
            roam: true,
            data: [],


            itemStyle: {
                normal: {
                    borderWidth: 1,
                    borderColor: '#0066CC',
                    color: '#3399FF',
                    label: {
                        show: true
                    }
                },
                emphasis: {                 // 也是选中样式
                    borderWidth: 1,
                    borderColor: '0066CC',
                    color: '#3399FF',
                    label: {
                        show: true,
                        textStyle: {
                            color: '#0066CC'
                        }
                    }
                }
            },

            markPoint: {
                symbolSize: 5,       // 标注大小，半宽（半径）参数，当图形为方向或菱形则总宽度为symbolSize * 2
                itemStyle: {
                    normal: {
                        borderColor: '#0066CC',
                        borderWidth: 1,            // 标注边线线宽，单位px，默认为1
                        label: {
                            show: false
                        }
                    },
                    emphasis: {
                        borderColor: '#000066',
                        borderWidth: 1,
                        label: {
                            show: false
                        }
                    }
                },
                data: stackMap_datas.PurchaseCountUnusualscale
            }
            ,

            geoCoord: { "天津市北辰区中医医院": [117.139, 39.2361], "天津市宝坻区钰华医院": [117.301, 39.6997], "天津市宝坻区人民医院": [117.315, 39.7253], "天津市宝坻区王卜庄医院": [117.451, 39.6904], "天津市宝坻区中医医院": [117.312, 39.7174], "天津市东丽区中医医院": [117.317, 39.0903], "天津市滨海新区汉沽医院": [117.807, 39.2503], "天津市滨海新区汉沽中医医院": [117.818, 39.2486], "天津市海河医院": [117.198, 39.115], "天津市和平区新兴街社区卫生服务中心": [117.196, 39.1071], "天津市和平区牙科医院": [117.193, 39.1346], "天津市和平区中医医院": [117.201, 39.1117], "天津市河西区挂甲寺街社区卫生服务中心": [117.244, 39.0963], "天津市河西区康复医院": [117.228, 39.1167], "天津市河西区口腔医院": [117.221, 39.1154], "海洋石油总医院": [117.708, 38.9976], "天津市静海县中医医院": [116.924, 38.9401], "天津市津南区咸水沽医院": [117.39, 38.9997], "天津市蓟县人民医院": [117.431, 40.0507], "天津市蓟县中医医院": [117.414, 40.0485], "天津市宁河县潘庄医院": [117.481, 39.3514], "天津市宁河县中医院": [117.689, 39.3816], "天津市南开区三潭医院": [117.161, 39.126], "天津市南开区王顶堤医院": [117.152, 39.0918], "天津医科大学第二医院": [117.227, 39.0901], "天津市滨海新区塘沽传染病医院": [117.615, 39.0379], "天津市滨海新区塘沽中医医院": [117.641, 39.0466], "天津市北辰医院": [117.138, 39.2318], "天津市第二人民医院": [117.157, 39.1171], "天津市中医药研究院附属医院": [117.184, 39.1522], "天津市大港医院": [117.483, 38.8376], "天津市东丽区东丽医院": [117.333, 39.1231], "天津市儿童医院": [117.205, 39.107], "天津市公安医院": [117.219, 39.1225], "天津港口医院": [117.724, 39.0089], "天津市环湖医院": [117.189, 39.0952], "天津市红桥医院": [117.164, 39.1878], "天津市黄河医院": [117.151, 39.144], "天津华兴医院": [117.454, 38.8535], "天津市静海县医院": [116.93, 38.9312], "天津市口腔医院": [117.212, 39.1334], "天津市宁河县医院": [117.834, 39.3413], "天津市南开医院": [117.177, 39.1337], "天津市人民医院": [117.163, 39.1527], "天津市泰达医院": [117.723, 39.0334], "天津市第五中心医院": [117.655, 39.0216], "天津市天津医院": [117.238, 39.0997], "天津市胸科医院": [117.393, 38.9698], "天津市西青医院": [117.027, 39.15], "天津市永久医院": [117.679, 39.0221], "天津市眼科医院": [117.192, 39.1305], "天津市职业病防治院": [117.246, 39.1587], "天津市肿瘤医院": [117.191, 39.0873], "泰达国际心血管病医院": [117.723, 39.0334], "天津市武清区人民医院": [117.06, 39.3868], "天津市武清区中医医院": [117.086, 39.3902], "天津医科大学代谢病医院": [117.19, 39.1103], "天津医科大学口腔医院": [117.192, 39.1104], "天津医科大学眼科中心": [117.127, 39.1041], "天津医科大学总医院": [117.193, 39.1238], "大港油田集团职工总医院": [117.51, 38.7464], "天津市第一医院": [117.195, 39.1859], "天津市第二医院": [117.199, 39.1565], "天津市第三医院": [117.247, 39.1591], "天津市第四医院": [117.27, 39.0674], "天津市第一中心医院": [117.159, 39.1062], "天津市第三中心医院": [117.256, 39.116], "天津市第四中心医院": [117.216, 39.1704], "天津中医药大学第二附属医院": [117.234, 39.1558], "天津中医药大学第一附属医院": [117.171, 39.1206] }
        },
        {
            name: '采购量预警',
            type: 'map',
            mapType: '天津',
            data: [],
            markPoint: {
                symbol: 'emptyCircle',
                symbolSize: function (v) {
                    return 5 + v / 1000
                },
                effect: {
                    show: true,
                    shadowBlur: 0
                },
                itemStyle: {
                    normal: {
                        label: { show: false }
                    }
                },
                data: stackMap_datas.PurchaseCountUnusualscale1
            }
        }
    ]
            };
            return $.extend({}, ECharts.ChartOptionTemplates.Map_AS, option);


        }
    }
 ,



    Charts: {
        RenderChart: function (option) {
            require([

                'echarts',
                'echarts/chart/line',
                'echarts/chart/bar',
                'echarts/chart/pie',
                'echarts/chart/k',
                'echarts/chart/scatter',
                'echarts/chart/radar',
                'echarts/chart/chord',
                'echarts/chart/force',
                'echarts/chart/map',
                'echarts/config'
                ],

              function (ec) {
                  echarts = ec;
                  var ecConfig = require('echarts/config');
                  var myChart = ec.init(document.getElementById('ctl00_ContentPlaceHolder1_echart'));
                  if (option.chart && option.chart.dispose)
                      option.chart.dispose();
                  option.chart = echarts.init(option.container);
                  window.onresize = option.chart.resize;
                  option.chart.setOption(option.option, true);


                  option.chart.on(ecConfig.EVENT.LEGEND_SELECTED, function (param) {
                      if (option.chart.chart.map != null) {
                          if (option.chart.chart.map.selectedMap.采购量预警 == true) {
                              var a = document.getElementById("ctl00_ContentPlaceHolder1_Label1");
                              var b = document.getElementById("ctl00_ContentPlaceHolder1_Label2");
                              a.style.display = "none";
                              b.style.display = "block";
                          }
                          else {
                              var a = document.getElementById("ctl00_ContentPlaceHolder1_Label1");
                              var b = document.getElementById("ctl00_ContentPlaceHolder1_Label2");
                              a.style.display = "block";
                              b.style.display = "none";
                          } 
                      }
                  });

              });



        }
    }
    ,

    RenderMap: function (option) { }


};
